<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        input{
            width: 200px;
            height: 30px;
            border-radius: 5px;
            outline: none;
            border: 1px solid white;
            background-color: #f7f0f0;
            transition: all 0.5s;
        }
        input:focus{
            width: 400px;
            height: 40px;
        }
        .box{
            position: relative;
            width: 400px;
        }
        .box .total{
            position: absolute;
            right: 5px;
            transition: all 0.5s;
            opacity: 0;
        }
    </style>
</head>
<body>
    <div class="box">
        <input type="search" placeholder="文本域">
        <div class="total">0/100字</div>
    </div>
    <script>
        const input = document.querySelector('input')
        const total = document.querySelector('.box .total')

        input.addEventListener('focus',function(){
            total.style.opacity = 1
        })
        input.addEventListener('blur',function(){
            total.style.opacity = 0
        })
        input.addEventListener('input',function(){
            total.innerHTML = `${input.value.length}/100字`
        })
    </script>
</body>
</html>